const mysql = require('mysql')
module.exports = {
    config: {
        host: 'localhost',
        port: '3306',
        user: 'root',
        password: '520520',
        database: 'softapi'
    },
    // 数据库连接池
    sqlConnect: function(sql,sqlArr,callback){
        const pool = mysql.createPool(this.config)
        pool.getConnection((err,conn) => {
            if(err){
                console.log('数据库连接失败')
                return;
            }
            conn.query(sql,sqlArr,callback)
            conn.release()  // 释放连接
        })
    }
}